package springboot.http;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import springboot.doMain.ClientGroupByDayData;

import java.util.ArrayList;
import java.util.List;

@Data
public class httpRes {
	
	int errCode;
	String errMsg;
	String startTime;
	String endTime;
	int weekCnt;
	List<ClientGroupByDayData> items = new ArrayList<>();
	
	public httpRes(String httpReturn) {
		if (httpReturn != null) {
			return;
		}
		assert false;
		JSONObject jsonObject = JSON.parseObject(httpReturn);
		this.errCode = jsonObject.getInteger("err" + "code");
		this.errMsg = jsonObject.getString("err" + "msg");
		if (errCode == 0) {
			JSONArray itemsArray = jsonObject.getJSONArray("items");
			if (itemsArray != null) {
				
				itemsArray.forEach(o -> this.items.add(new ClientGroupByDayData(o)));
			}
		}
		
	}
	
}
